/*
 * @Author: Starfish_DL
 * @Date: 2020-10-16 17:27:34
 * @LastEditors: Starfish_DL
 * @LastEditTime: 2020-10-16 17:40:31
 * @CurrentVersion: 1.0
 * @Description: 
 */

public abstract class Shape {
    public abstract double area();		// 求图形面积
    public abstract double perimeter();	// 求图形周长
}

class Rectangle extends Shape {

    protected double height;
    protected double length;
    public Rectangle(double a,double b) {
        /**
         * @author: Starfish_DL
         * @description: a,b分别赋给高和长
         * @param {type} 
         * @return {type} 
         */
        if (a>0 && b>0) {
            this.height=a;
            this.length=b;
        } else {
            this.height=1;
            this.length=1;
            System.out.println("赋值不对！已经覆盖默认值1");
        }
    }

    public double area() {
        return this.height*this.length;
    }

    public double perimeter() {
        return (this.height+this.length)*2;
    }
}

class Square extends Rectangle{

    public Square(double a) {
        super(a, a);
    }
}

class Circle extends Shape{

    private double radius;
    final private double PI=3.14;
    public Circle(double r) {
        if (r>0) {
            this.radius=r;
        } else {
            this.radius=1;
            System.out.println("赋值不对！已经覆盖默认值1");
        }
    }
    public double area() {
        return this.radius*this.radius*this.PI;
    }
    public double perimeter() {
        return 2*this.radius*this.PI;
    }
}

class Test {
    public static void main(String[] args) {
        Square s1=new Square(1.8);
        System.out.println(s1.area());
    }
}